import React, { useRef, useState, useEffect } from 'react';
import { connect } from 'umi';
import TableDataBlock from '@/components/TableDataBlock';
import { reloadTab } from '@/utils/utils';
import { notification } from 'antd';
import { Button, Modal, Space, Form, Row, Col } from 'antd';
import FormCondition from '@/components/FormCondition';
import { useUpdateEffect } from 'ahooks';
const AuthFormSetting = (props) => {
  const {
    visible = false,
    onClose,
    loading,
    userFieldRecordList,
    form
  } = props;
  const { show = false, detail = {}, } = visible;
  const { fieldName } = detail
  const [selectedRowKeys, setSelectedRowKeys] = useState([])
  const getColumns = [

    {
      title: '字段名称描述',
      dataIndex: 'fieldNameDesc',
    },

    {
      title: '字段值描述 ',
      dataIndex: 'fieldValueDesc',
    },
    {
      title: '记录类型',
      dataIndex: 'recordType',
      render: (e) => {
        return {
          add: '添加',
          edit: '编辑'
        }[e]
      }
    },
    {
      title: '创建时间',
      dataIndex: 'createTime',
    },
    {
      title: '员工姓名',
      dataIndex: 'adminName',
    },
    {
      title: '用户姓名',
      dataIndex: 'username',
    },
    {
      title: '操作者类型',
      dataIndex: 'operationType',
      render: (e) => {
        return {
          user: '用户',
          admin: '员工',
          system: '系统',
          openApi: '开放平台',
        }[e]
      }
    },

  ];
  const rowSelection = {
    type: 'radio',
    onChange: (e) => {
      setSelectedRowKeys(e)
    },
    selectedRowKeys: selectedRowKeys.map((item) => {
      return item.id.toString();
    }),
    preserveSelectedRowKeys: true,
  };
  const modalProps = {
    title: `修改记录`,
    width: 1200,
    visible: typeof visible === 'boolean' ? visible : show,
    maskClosable: true,
    destroyOnClose: true,
    zIndex: 10001,
    confirmLoading: loading,
    footer: null
    // footer: <Button onClick={() => {
    //   form.setFieldsValue({
    //     [fieldName]: 123
    //   })
    // }}>修改</Button>
  };

  return (
    <Modal {...modalProps} onCancel={onClose}>
      <TableDataBlock
        // rowSelection={rowSelection}
        params={{
          ...detail,
        }}
        loading={loading}
        columns={getColumns}
        rowKey={(record) => `${record.id}`}
        dispatchType="user/fetchUserFieldRecord"
        {...userFieldRecordList}
      ></TableDataBlock>


    </Modal>
  );
};

export default connect(({ user, loading }) => ({
  ...user,
  loading: loading.models.user
}))(AuthFormSetting);
